package com.dushibao.utils;

import com.dushibao.entity.Menu;

import java.util.List;
import java.util.stream.Collectors;

public class CommUtils {
    public static boolean contains(List lists,Object obj){

        return lists.contains(obj);
    }

    public static String menuName(List<Menu> menus,Long id){
        for (Menu menu : menus) {
            if(menu.getId().equals(id)){
                return menu.getName();
            }
            for (Menu child : menu.getChilds()) {
                if(child.getId().equals(id)){
                    return child.getName();
                }
            }
        }
        return "默认";
    }

    /**
     * 以exts结尾 或者包含 比如/user/loginFinish 是登录请求 不需要拦截
     * @param exts
     * @param path
     * @return
     */
    public static boolean endWith(List<String> exts,String path){
        for (String ext : exts) {
            if(path.endsWith(ext) || path.contains(ext)){
                return true;
            }
        }
        return false;
    }



}
